/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ControlEscolar.Services;

import com.ControlEscolar.Beans.ExamRequest;
import com.ControlEscolar.DAOs.DAOException;
import com.ControlEscolar.DAOs.ExamRequestDAO;
import com.ControlEscolar.Exceptions.ServiceExp;
import com.ControlEscolar.Validations.ValidationExamRequest;
import java.util.ArrayList;


/**
 *
 * @author Bere
 */
public class ExamRequestService {

    ExamRequestDAO examRequestDAO=new ExamRequestDAO();
    ValidationExamRequest validationExamRequest=new ValidationExamRequest();

    public void createExamRequest(ExamRequest examRequest) throws ServiceExp{
        try {
            examRequestDAO.add(examRequest);
        } catch (DAOException ex) {
            throw new ServiceExp();
        }

    }

    public void updateExamRequest(ExamRequest examRequest) throws ServiceExp {
        try {
            examRequestDAO.update(examRequest);
        } catch (DAOException ex) {
            throw new ServiceExp();
        }
    }

    public ArrayList<ExamRequest> getAllExamRequests() throws ServiceExp{
        try {
            return examRequestDAO.query();
        } catch (DAOException ex) {
            ex.printStackTrace();
            throw new ServiceExp();
        }
    }

    public ExamRequest getExamRequestById(long id) throws ServiceExp{
        try {
            return examRequestDAO.queryByID(id);
        } catch (DAOException ex) {
            throw new ServiceExp();
        }
    }
}
